import * as g_session from '../cache/app_session'
import * as g_cookie from '../cache/app_cookie'

const cache_user_key = 'user'
const cache_token_key = 'u-token'

/**
 * 从localStore取出用户信息
 */
export function getUser() {
    let user = g_session.getLocalCache(cache_user_key)
    if (user) {
        return user
    } else {
        user = {}
    }
    return user
}

/**
 * 将用户信息放入localStore
 * @param {*} user 
 */
export function setUser(user) {
    g_session.setLocalCache(cache_user_key, user)
}

/**
 * 从cookie中取出用户信息
 */
export function getToken() {
    g_cookie.get_cookie(cache_token_key)
}


